package com.wongoing.test;

import java.net.URL;

import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;

public class MyResourceLoader extends DefaultResourceLoader {
	
	@Override
	public Resource getResource(String location) {

		//System.out.println("文件路径地址：" + location);
		try
		{
			if (location != null && location.startsWith("/WEB-INF/content"))
			{
				//System.out.println(System.getProperty("user.dir"));
				location = location.replace("/WEB-INF/content/", "");
				//URL url = new URL("file:/F:/数据服务部-2016/配置库/Archimedes/01工程域/04系统实现/04后台系统/Archimedes/src/" + location);
				URL url = new URL("file:/" + System.getProperty("user.dir") + "/src/" + location);
				return new UrlResource(url);
			}
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
		
		return null;
	}
}
